package com.apes.hr.entry;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.DateUtil;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * @Title: EntryInformationFamily
 * @Description: 入职资料补充之家庭成员
 * @author: ZhengZeXian
 * @create: 2021/3/12 17:21
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = EntryInformationFamily.CONST_TABLE_NAME)
public class EntryInformationFamily extends Model {

    public static final String CONST_TABLE_NAME = "hr_entry_information_family";

    @Id
    @Column(name = "id", length = 24)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "员工资料补充家庭成员编码")
    @Comment("入职资料家庭成员编码")
    private String id;

    @ManyToOne
    @JoinColumn(name = "entryInformation_id", referencedColumnName="id")
    @Comment("入职资料单号")
    private EntryInformation entryInformation;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "relation_id", referencedColumnName = "id")
    @Comment("关系")
    private Enumeration relation;

    @Column(name = "name", nullable = false, length = 16)
    @Comment("姓名")
    private String name;

    @JSONField(format = DateUtil.SHOW_DATE_FORMAT)
    @Temporal(TemporalType.DATE)
    @Column(name = "birthday")
    @Comment("生日")
    private Date birthday;

    @Column(name = "work_unit", length = 32)
    @Comment("工作单位")
    private String workUnit;

    @Column(name = "jobs",  length = 16)
    @Comment("职务")
    private String jobs;

    @Column(name = "mobile_number", length = 16)
    @Comment("手机号")
    private String mobileNumber;
}
